package com.yazi.mxz.common.db.dao.impl;



import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.yazi.mxz.common.db.dao.AdminRoleDao;
import com.yazi.mxz.common.entity.beans.AdminRole;
import com.yazi.mxz.common.entity.beans.AdminRoleId;

import com.myframework.smhj.hibernate.dao.BasicDao;

@Repository("adminRoleDao")
public class AdminRoleDaoImpl extends BasicDao<AdminRole> implements AdminRoleDao {

	
	public AdminRoleDaoImpl() {
		super(AdminRole.class);
		
	}

	@Override
	public Criteria getExample(AdminRole ar, String searchWord) {
		Criteria c = super.getExample(ar, searchWord);
		
		// 关联对象条件
		if (null != ar) {
			// ID
			AdminRoleId arId = ar.getId();
			if (null != arId) {
				if (null != arId.getAdminId()) {
					c.add(Restrictions.eq("id.adminId", arId.getAdminId()));
				}
				if (null != arId.getRoleId()) {
					c.add(Restrictions.eq("id.roleId", arId.getRoleId()));
				}
			}
			// ...其它关联对象条件
		}
		
		// ...关键字searchWord条件
		
		return c;
	}

}
